<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>退款单新增</title>
    <style type="text/css">
        .items2 ul{ }
        .items2 ul li{margin-bottom: 10px;border: 1px solid #ffffff;height: 30px;line-height: 30px;padding: 0 5px;}
        .items2 ul li.selected {background-color: #E8F1FF;border: 1px solid #B2D1FF;box-shadow: 2px 2px 0 #E5E5E5;font-weight: bold;}
    </style>
</head>

<body>
<div style="width:100%">

    <div class="container">
        <div class="comm_crub">
            <span class="now_crub">退款单新增</span>
        </div>

        <div class="comm_content">

        <div class="bs-example">
            <ul class="nav nav-tabs" role="tablist">
                <li class="active" role="presentation">
                    <a href="#">退款单信息</a>
                </li>
            </ul>
        </div>
            <div style="margin-top: 10px;">
                <form name="refund_form" id="refund_form" class="form-horizontal" onsubmit="return false;" >

                    <div class="form-group">
                        <label for="bill_no" class="col-sm-3 control-label"> 订单号：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="bill_no" name="bill_no" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label"><span class="red">*</span> 退款来源：</label>
                        <div class="col-sm-9">
                            <select class="form-control w150 fl" name="refund_source" id="refund_source" >
                                <option value="">请选择...</option>
                                <option  value="1">订单退货</option>
                                <option  value="2">订单取消</option>
                                <option  value="3">其他</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="return_no" class="col-sm-3 control-label"> 退货单号：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="return_no" name="return_no" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label"> 支付方式：</label>
                        <div class="col-sm-9">
                            <select class="form-control w150 fl" name="payType" id="payType" >
                                <option value="">请选择...</option>
                                <!--{foreach from=$payType item=value}-->
                                <option value="<!--{$value->payTypeID}-->_<!--{$value->payTypeName}-->"><!--{$value->payTypeName}--></option>
                                <!--{/foreach}-->
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="payee" class="col-sm-3 control-label"> 收款人：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="payee" name="payee" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="refund_type_name" class="col-sm-3 control-label"> 退款方式：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="refund_type_name" name="refund_type_name" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="refund_account" class="col-sm-3 control-label"> 退款账号：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="refund_account" name="refund_account" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="refund_amount" class="col-sm-3 control-label"><span class="red">*</span> 退款金额：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control w300" id="refund_amount" name="refund_amount" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="remark" class="col-sm-3 control-label"> 备注：</label>
                        <div class="col-sm-9">
                            <textarea  class="form-control" id="remark" name="remark" style="width:450px;" placeholder="请输入备注信息" ></textarea>
                        </div>
                    </div>

                </form>
        </div>

            <div class="bottom_fixbox">
                <div class="tac" style="background: #dddddd;">
                    <input type="button" class="btn btn-primary" onclick="bill.save();" value="保存" />&nbsp;&nbsp;&nbsp;
                    <input type="button" class="btn btn-default" onclick="E.closeWindows();" value="关闭" />
                </div>
            </div>
    </div>

    </div>

</div>

<script type="text/javascript" src="/inc/config/default/region.min.js"></script>
<script type="text/javascript" src="/framework/ebsig/js/region.change.min.js"></script>

<script type="text/javascript">

    var bill = {

        save : function (){

            //错误提示
            var error_msg = '';

            //获取表单数据
            var serializeArray = $("#refund_form").serializeArray();

            //提交的数据数组
            var dt = { };

            //处理表单数据后重新赋值
            $.each(serializeArray,function (k,v){
                dt[v['name']] = $.trim(v['value']);
            });

            //如有订单号检查订单号
            if(dt['bill_no'] != '' && !E.isDigital(dt['bill_no']) ){
                error_msg += "请输入正确的订单号<br/>";
            }

            //检查退款来源
            if(dt['refund_source'] == ''){
                error_msg += "请选择退款来源<br/>";
            }

            //如有订单号检查订单号
            if(dt['return_no'] != '' && !E.isDigital(dt['return_no']) ){
                error_msg += "请输入正确的退货单号<br/>";
            }

            //检查退款金额
            if(!E.isMoney(dt['refund_amount'])){
                error_msg += "请输入正确的退款金额<br/>";
            }


            if(error_msg != ''){
                E.alert(error_msg);
                return false;
            }

            dt['refund_no'] = "";

            E.ajax_post({
                url: "/invokingAjax-backend/bill/billRefund.ajax?operFlg=2",
                data: {
                    data: dt
                },
                call: "bill.result"
            });

        },

        result : function (response){
            if(response.code != 200){
                E.alert(response.message);
                return;
            }

            E.opener("bill.search");

            E.alert("保存成功",2,"bill.reload");


        },

        reload : function (){
            window.location.reload();
        }

    };

</script>


</body>
</html>
